<template>
  <uni-page-wrapper>
    <uni-page-body>
      <uni-view class="back">
        <uni-view class="bg">
          <uni-view class="box">
            <uni-image class="left">
              <div
                style="
                  background-image: url('/static/img/avatar.42fc3f14.png');
                  background-position: 0% 0%;
                  background-size: 100% 100%;
                  background-repeat: no-repeat; 
                "
              >
            </div>
              <img src="/static/img/avatar.42fc3f14.png" />
            </uni-image>
            <uni-view class="center">
              <uni-view class="t">{{$t("invitation.Quickly share")}}</uni-view>
              <uni-view class="b">{{$t("invitation.Invitation code")}}：{{ invitationCode }}</uni-view>
            </uni-view>
            <uni-view class="right" v-clipboard:copy="register"
	v-clipboard:success="(type) => onCopyResult('success')"
	v-clipboard:error="(type) => onCopyResult('error')">{{$t("invitation.copy")}}</uni-view>
          </uni-view>
          <image class="code" :src="QRCode">
          </image>
        </uni-view>
      </uni-view>
    </uni-page-body>
  </uni-page-wrapper>
</template>

<script>
import service from '@/store/service.js'
export default {
  data() {
    return {
      invitationCode: "",
      QRCode: "",
	  register: ''
    };
  },
  mounted() {
  	service.auth(this,service.api.app_getcode,{},function(self,res){
		self.invitationCode = res.code
		self.QRCode = res.qr_code
		self.register = res.regurl
	})
  },
  methods:{
	  onCopyResult(type) {
	  	if (type==='success') {
			uni.showToast({
				icon:'none',
				title:this.$t("invitation.copy successed")
			})
	  	} else {
			uni.showToast({
				icon:'none',
				title:this.$t("invitation.copy failed")
			})
	  	}
	  }
  }
};
</script>

<style>
@import url(./invitation.css);
</style>